-
Notifications
You must be signed in to change notification settings - Fork 77
Automatically install or update ocaml-lsp-server #1725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Pizie, this looks quite reasonable and works great.
I understand now the "notifications" you were talking about earlier:

Maybe we could improve the message of the "Installing sandbox packages" to also mention the name of the packages so that we could remove the additional "Installing the latest release of...." notification ?
Co-authored-by: Ulysse <[email protected]>
Co-authored-by: Ulysse <[email protected]>
Co-authored-by: Ulysse <[email protected]>
I have one concern with the current behavior: what install package does is:
edit: Just tested it, and opam is not upgrading the switch by default, so we are all good here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good. I have a few suggestions left for the upgrades 🙂
src/extension_instance.ml
Outdated
|
||
let upgrade_ocaml_lsp_server sandbox latest_version = | ||
let open Promise.Syntax in | ||
let+ () = Sandbox.install_packages sandbox [ "ocaml-lsp-server=" ^ latest_version ] in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be much better to modify Sandbox.upgrade_packages to accept a list of packages to upgrade and use that.
That way you wouldn't have to carry the 'latest_version' around and concatenate strings to try to install the latest version. Opam knows how to do that better :-)
You might want to rename Sandbox.upgrade_packages to Sandbox.upgrade_all_packages and then introduce the specialized Sandbox.upgrade_packages to work on a given list of packages.
Co-authored-by: Ulysse <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot Pizie, that looks quite close to being ready :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just made a few more remarks, but once fixed I think this is ready to go.
In my opinion this hints toward a long-awaited refactoring of how we check for available commands. It could be unified so that we have the same behavior for every command: Not available ? Then do you want to upgrade ? Nice. Arg.
But that's the subject of another PR.
Co-authored-by: Ulysse <[email protected]>
Co-authored-by: Ulysse <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Pizie, I think the current state is all-right for introducing this new functionality.
We might want to do some refactoring / cleanup of the mechanism to detect missing features in the future.
* check if ocaml-lsp-server is installed * suggest to install ocaml-lsp-server * command to install ocaml-lsp-server * linting * add changelog * remove type annotations * Update src/extension_instance.ml Co-authored-by: Ulysse <[email protected]> * Update src/extension_commands.ml Co-authored-by: Ulysse <[email protected]> * Update package.json Co-authored-by: Ulysse <[email protected]> * displayy packages in installation notification * lint * Update package.json Co-authored-by: Ulysse <[email protected]> * modify to include latest version * prompt user to update ocaml-lsp-server if outdated * correct sandbox spelling * better notification messages * ask user to upgrade or do nothing * correct typo * lint * Update src/sandbox.ml Co-authored-by: Ulysse <[email protected]> * use variants and not strings * pass a list of packages to upgrade * update opem upgrade to take a an optional list of packages * revert * remove latest_version from function * use consistent annotations * remove latest_Version * make suggets_to_update_lsp public * suggest to upgrade lsp when using old version * wait for promises to resolve * suggest to upgrade ocaml_lsp in ocaml_lsp.is_version_up_to_date * Update src/ocaml_lsp.ml Co-authored-by: Ulysse <[email protected]> * Update src/extension_instance.ml Co-authored-by: Ulysse <[email protected]> * better error handling --------- Co-authored-by: Ulysse <[email protected]>
Currently, when
ocaml-lsp-server
is not found in a sandbox, the language server displays an error and fails to start.This PR improves users experience by providing a UI that asks if they will like to install or update
ocaml-lsp-server
or select another sandbox.If the user wants to select another sandbox, a quickpick will be displayed with various switches.
If the user decides to install
ocaml-lsp-server
, it will be installed in the background and they can continue with their activities in the editor.This PR will streamline the process for complete beginners and also reduce the time to terminal for experienced users who often will have to switch to the terminal to install
ocaml-lsp-server
in their sandbox.cc @voodoos